<template>
  <div>
    <h3>页面丢了</h3>
    <hr />
    {{ num }}
    <hr />
    <router-link to="/home">去首页</router-link>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 5,
      timer: null,
    };
  },
  mounted() {
    this.timer = setInterval(() => {
      console.log(this.num);
      if (this.num == 0) this.$router.replace("/home");
      this.num--;
    }, 1000);
  },
  beforeDestroy() {
    // 生命周期清除动画
    clearInterval(this.timer);
  },
};
</script>

<style lang="scss" scoped>
</style>